home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / LIB / GLSMAP / smap_destroy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  650 b   |  34 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1998.  */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <assert.h>
  9. #include <stdlib.h>
  10.  
  11. #include "glsmapint.h"
  12.  
  13. static void
  14. derefSphereMapMesh(SphereMapMesh *mesh)
  15. {
  16.     assert(mesh->refcnt > 0);
  17.     mesh->refcnt--;
  18.     if (mesh->refcnt == 0) {
  19.         if (mesh->face) {
  20.             assert(mesh->back ==
  21.                 &(mesh->face[5*mesh->steps*mesh->steps]));
  22.             free(mesh->face);
  23.         }
  24.         free(mesh);
  25.     }
  26. }
  27.  
  28. void
  29. smapDestroySphereMap(SphereMap *smap)
  30. {
  31.     derefSphereMapMesh(smap->mesh);
  32.     free(smap);
  33. }
  34.